package com.system.registrationPool.controller;

import com.system.registrationPool.bean.RegistrationPool;
import com.system.registrationPool.bean.RegistrationPoolList;
import com.system.registrationPool.service.RegistrationPoolService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.util.List;

/**
 * @author 林
 */
@RestController
@RequestMapping("/registrationPool")
public class RegistrationPoolController {
    @Autowired
    private RegistrationPoolService registrationPoolService;

    @PostMapping("/save")
    public Integer saveHandle(@RequestBody RegistrationPool registrationPool){
        return registrationPoolService.saveRegistrationPool(registrationPool);
    }

    @DeleteMapping("/del/{id}")
    public boolean deleteHandle(@PathVariable("id") int id){
        return registrationPoolService.removeRegistrationPoolById(id);
    }

    @PutMapping("/update")
    public boolean updateHandle(@RequestBody RegistrationPool registrationPool){
        return registrationPoolService.modifyRegistrationPool(registrationPool);
    }

    @GetMapping("/get/{id}")
    public RegistrationPool getHandle(@PathVariable("id") int id){
        return registrationPoolService.getRegistrationPoolById(id);
    }

    @GetMapping("/get/list")
    public List<RegistrationPool> listHandle(){
        return registrationPoolService.listAllRegistrationPools();
    }

    @GetMapping("/get/listByBusinessAndPoolDt/{businessId}/{poolDt}")
    public List<RegistrationPool> listByBusinessAndPoolDt(
            @PathVariable("businessId") int businessId,
            @PathVariable("poolDt") LocalDate poolDt
    ) {
        return registrationPoolService.findAllByBusinessIdAndPoolDt(businessId, poolDt);
    }



}
